;
(function() {
	new Vue({
		el: '#visitor-detail',
		data: {
			typeArcms: {
				radio: [],
				check: [],
				input: [],
				text: []
			},
			id: hlUrlUtil.GetQueryString('id'),
			detailData: {projectInfo: {units: [],wps: [], wpsRecombination: []}, customConfigProperty: []},
			tmpData: []
		},
		filters: {
			formatDatehms: function (time) {
			  if (time === undefined) return '--'
			  return hlDateUtil.formatUTCDate(time, 'yyyy-MM-dd HH:mm:ss')
			},
			formatDate: function (time) {
			  if (time === undefined) return '--'
			  return hlDateUtil.formatUTCDate(time, 'yyyy-MM-dd')
			},
		},
		methods: {
			//编辑
			toEditor () {
				hlUrlUtil.goTo('intentionalEditor', { ddtab: true, clear: true, id: this.id }, false)
			},
			getDetail() {
				hlhttp.get({
					url: 'visitor_form_info',
					data: {
						id: this.id
					},
					success: (data) => {
						this.tmpData = data.pageCustomizeComponentBizContentList ? data.pageCustomizeComponentBizContentList : []
						data.customConfigProperty = JSON.parse(data.customConfigProperty)
						this.detailData = data;
						if (data.projectInfo) {
							if (data.projectInfo.wps) {
								let newData = hlArrayUtil.removeRepeat(data.projectInfo.wps, 'unit_id')
								newData.map(item => {item.child = []})
								data.projectInfo.wps.map(item1 => {
									newData.map(item2 => {
										if (item1.unit_id == item2.unit_id) {
											item2.child.push({name: item1.wpName, id: item1.wpId})
										}
									})
								})
								data.projectInfo.wpsRecombination = newData
							}	else {
								this.detailData.projectInfo.wpsRecombination = []
							}
						} else {
							this.detailData.projectInfo = {units: [], wps: [], wpsRecombination: []}
						}				
					}
				})
			},
			
		},
		mounted() {
			this.getDetail()
		}
	})
}())
